package com.scbo.utility;

import java.util.ArrayList;
import java.util.List;

import com.scbo.DTO.Buildorder;
import com.scbo.DTO.ItemBO;
import com.scbo.activity.MainActivity;
import com.scbo.main.R;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class BuildOrderArrayAdapter extends ArrayAdapter<Buildorder> {

	Context context = null;
	ArrayList<Buildorder> itemList = null;

	public BuildOrderArrayAdapter(Activity context, ArrayList<Buildorder> listItems) {
		super(context, R.layout.list_item_create, listItems);
		this.context = context;
		this.itemList = listItems;
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		// LayoutInflater inflater = context.getLayoutInflater();
		View listView  = convertView;
		listView = inflater.inflate(R.layout.list_item_create, parent,
				false);
		TextView txtTimeShow = (TextView) listView
				.findViewById(R.id.txtTimeShow);
		TextView txtTextShow = (TextView) listView
				.findViewById(R.id.txtTextShow);
		Buildorder item = itemList.get(position);
		String typeMatchBO ="";
		
		switch (item.getTypeMatch()) {
		case 1:
			typeMatchBO = "TvsT"; 
			break;
		case 2:
			typeMatchBO = "TvsP"; 
			break;
		case 3:
			typeMatchBO = "TvsZ"; 
			break;
		case 4:
			typeMatchBO = "PvsT"; 
			break;
		case 5:
			typeMatchBO = "PvsP"; 
			break;
		case 6:
			typeMatchBO = "PvsZ"; 
			break;
		case 7:
			typeMatchBO = "ZvsT"; 
			break;
		case 8:
			typeMatchBO = "ZvsP"; 
			break;
		case 9:
			typeMatchBO = "ZvsZ"; 
			break;

		default:
			typeMatchBO = "other";
			break;
		}
		txtTimeShow.setText(typeMatchBO);
		txtTextShow.setText(item.getName());

		return listView;
	}

}
